//
//  Server.Request.swift
//  Merchant
//
//  Created by 薛永伟 on 2019/5/14.
//  Copyright © 2019 Yuri. All rights reserved.
//

import Foundation
import Alamofire
import SwiftyJSON

extension API {
    
    /// 信息流
    class D:NSObject,APIUrlable{}
    
    /// 特殊规则的
    class Specail:NSObject{}
    
}

extension API.Specail {
    
    
}

//MARK: - --------------Common--------------
extension API.D {
    
    
    static func Base_URL() -> String {
        
        return API.Base_URL() + "/d/api/2.0/ios/2.0"
    }
    
//    /// 信息流列表接口-本地
//    static func feedList(type_id:Int,
//                         start:Int,
//                         limit:Int,
//                         complete:@escaping API.CompleteBlock){
//
//        let url = urlWithPath("/feedList")
//        let param = ["type_id":type_id,"start":start,"limit":limit]
//        API.request(url, method: .get,parameters: param).serverResponse(complete: complete)
//    }
    
    /// 信息流列表接口-本地
    static func feedListNight(type_id:Int,
                         start:Int,
                         limit:Int,
                         area:String,
                         complete:@escaping API.CompleteBlock){
        
        let url = urlWithPath("/feedListNight")
        let param = ["type_id":type_id,"start":start,"limit":limit,"area":area] as [String : Any]
        API.request(url, method: .get,parameters: param).serverResponse(complete: complete)
    }
    
    /// 获取信息流分类
    static func getFeedType(complete:@escaping API.CompleteBlock){
        
        let url = urlWithPath("/getFeedType")
        API.request(url).serverResponse(complete: complete)
    }
    
    /// 获取表信息流详情推荐列表
    static func getFeedRecommendList(id:String,
                                     num:Int = 6,
                                     complete:@escaping API.CompleteBlock){
        
        let url = urlWithPath("/getFeedRecommendList")
        let param = ["id":id,"num":num] as [String : Any]
        API.request(url, method: .get,parameters: param).serverResponse(complete: complete)
    }
    
    /// 位置ID
    enum ADPlacementID:Int {
        case feed = 16
        case splash = 17
        case land = 18
        case userInfo = 19
    }
    
    /// 获取表信息流详情推荐列表;
    static func getAd(area:String,
                      id:ADPlacementID,
                      complete:@escaping API.CompleteBlock){
        
        let url = urlWithPath("/getAd")
        let param = ["area":area,"id":id.rawValue] as [String : Any]
        API.request(url, method: .get,parameters: param).serverResponse(complete: complete)
    }
    
}

